package com.xiaoqi.exception;

import com.xiaoqi.pojo.Result;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author PC
 * creationTime: 2022/10/18 11:07
 */
@RestControllerAdvice//对所有带有@Controller注解的类进行增强
public class ControllerExceptionHandler {


    @ExceptionHandler(SunnydayException.class)//捕获sunnydayExceptiony异常
    public Result sunnydayExceptionhandle(SunnydayException se){
        return new Result(false, se.getMessage());
    }

    @ExceptionHandler(AccessDeniedException.class)//捕获sunnydayExceptiony异常
    public Result AccessDeniedException(AccessDeniedException ade){
        return new Result(false, ade.getMessage()+"权限不足!");
    }

}
